<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>下载对账单接口测试</title>
    <link href="../css/weui.min.css" rel="stylesheet">
    <link href="../css/example.css" rel="stylesheet">
</head>
<body ontouchstart>
    <div class="page__hd">
        <h1 class="page__title">
            下载对账单接口
        </h1>
        <p class="page__desc">请输入日期，并选择账单类型，再进行下载</p>
        <p class="page__desc" id="result"></p>
    </div>
    <div class="page__bd">
        <div class="weui-cells__title">表单</div>
        <div class="weui-cells">
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">账单日期</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" id="billDate" type="date" required placeholder="请选择日期"/>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">账单类型</label>
                </div>
                <div class="weui-cell__bd">
                    <select class="weui-select" id="billType">
                        <option value="ALL" selected>当日所有订单信息</option>
                        <option value="SUCCESS">当日成功支付的订单</option>
                        <option value="REFUND">当日退款订单</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="weui-btn-area">
            <a href="javascript:;" id="downloadBill" class="weui-btn weui-btn_primary">下载对账单</a>
        </div>
    </div>
    <div class="page__ft"></div>
    <script src="../js/jquery-1.9.1.min.js"></script>
    <script>
        $("#downloadBill").click(function () {
            var billDate = $("#billDate").val();
            if(!billDate) {
                $("#result").text("请选择日期");
                return;
            } else {
                billDate = billDate.replace(/-/g,"");
            }
            $(this).hide();
            $("#result").text("正在下载...");
            // 调用下载接口
            $.ajax({
                url: "/wxpay/downloadBill/doDownloadBill.do",
                dataType:'json',
                data: {billDate : billDate, billType: $("#billType").val()},
                type: "POST",
                success:function(data){
                    $("#result").text(JSON.stringify(data));
                    $("#downloadBill").show();
                },
                error:function () {
                    alert("error");
                }
            });
        });
    </script>
</body>
</html>